﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     ServiceAttachment业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class ServiceAttachmentSqlMapDao : BaseSqlMapDao, IServiceAttachmentDao
    {
        private static ServiceAttachmentSqlMapDao instance = null;
        private static object syncRoot = new object();

        private ServiceAttachmentSqlMapDao()
        {
            //
            // TODO: 此处添加ServiceAttachmentSqlMapDao的构造函数
            //
        }
        public static IServiceAttachmentDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new ServiceAttachmentSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectServiceAttachmentByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceAttachment> GetList()
        {
            try
            {
                return ExecuteQueryForList<ServiceAttachment>("SelectServiceAttachment", null);
            }
            catch
            {
                throw; 
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<ServiceAttachment> GetListByParameters(Hashtable ht)
        {
            try
            {
                return ExecuteQueryForList<ServiceAttachment>("SelectServiceAttachmentByParameters", ht);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="AttachmentID"></param>
        /// <returns></returns>
        public ServiceAttachment GetDetail(System.String attachmentid)
        {
            try
            {
                return ExecuteQueryForObject<ServiceAttachment>("SelectServiceAttachment", attachmentid) as ServiceAttachment;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="serviceattachment"></param>
        /// <returns></returns>
        public object Add(ServiceAttachment serviceattachment)
        {
            //int id = GetId("ServiceAttachment");
            //serviceattachment.AttachmentID = id;

            try
            {
                return ExecuteInsert("InsertServiceAttachment", serviceattachment);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="serviceattachment"></param>
        /// <returns></returns>
        public int Update(ServiceAttachment serviceattachment)
        {
            try
            {
                return ExecuteUpdate("UpdateServiceAttachment", serviceattachment);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="AttachmentID"></param>
        /// <returns></returns>
        public int Delete(System.String attachmentid)
        {
            try
            {
                return ExecuteDelete("DeleteServiceAttachment", attachmentid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="serviceattachment"></param>
        /// <returns></returns>
        public int Delete(ServiceAttachment serviceattachment)
        {
            try
            {
                return ExecuteDelete("DeleteServiceAttachment", serviceattachment.AttachmentID);
            }
            catch
            {
                throw;
            }
        }

        public int Delete(Hashtable ht)
        {
            try
            {
                return ExecuteDelete("DeleteServiceAttachByList", ht);
            }
            catch 
            {
                
                throw;
            }
        }
    }
}
